home *** CD-ROM | disk | FTP | other *** search
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
-
- public class zjtext extends Applet implements Runnable {
- static final int MAXCLORS = 10;
- // $FF: renamed from: s java.lang.String
- String field_0;
- Thread jitterThread;
- boolean threadSuspended = false;
- int fontHeight;
- Color textColor;
- Color bgColor;
- int speed = 200;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_1;
- int baseline;
- Image offScrImage;
- Graphics offScrGC;
- boolean normal = false;
- Font font;
- Color[] randomColors = new Color[10];
- boolean randomColor = false;
-
- public void init() {
- Graphics var2 = ((Component)this).getGraphics();
- this.fontHeight = ((Component)this).size().height - 10;
- this.offScrImage = ((Component)this).createImage(((Component)this).size().width, ((Component)this).size().height);
- this.offScrGC = this.offScrImage.getGraphics();
- this.field_0 = ((Applet)this).getParameter("text");
- if (this.field_0 == null) {
- this.field_0 = "Java Power!";
- }
-
- int var3 = ((Component)this).size().width - (this.field_0.length() + 1) * 5 - 10;
-
- do {
- var2.setFont(new Font("TimesRoman", 1, this.fontHeight));
- this.field_1 = var2.getFontMetrics();
- if (this.field_1.stringWidth(this.field_0) > var3) {
- --this.fontHeight;
- }
- } while(this.field_1.stringWidth(this.field_0) > var3);
-
- this.baseline = ((Component)this).size().height - this.field_1.getMaxDescent();
- this.font = new Font("TimesRoman", 1, this.fontHeight);
- String var1;
- if ((var1 = ((Applet)this).getParameter("TEXTCOLOR")) == null) {
- this.textColor = Color.black;
- } else {
- this.textColor = this.parseColorString(var1);
- }
-
- if ((var1 = ((Applet)this).getParameter("BGCOLOR")) == null) {
- this.bgColor = Color.lightGray;
- } else {
- this.bgColor = this.parseColorString(var1);
- }
-
- ((Component)this).setBackground(this.bgColor);
- if ((var1 = ((Applet)this).getParameter("SPEED")) != null) {
- this.speed = Integer.valueOf(var1);
- }
-
- if (this.speed == 0) {
- this.speed = 200;
- }
-
- if ((var1 = ((Applet)this).getParameter("RANDOMCOLOR")) != null) {
- this.randomColor = Integer.valueOf(var1) != 0;
- }
-
- this.randomColors[0] = Color.magenta;
- this.randomColors[1] = Color.orange;
- this.randomColors[2] = Color.red;
- this.randomColors[3] = Color.white;
- this.randomColors[4] = Color.yellow;
- this.randomColors[5] = Color.blue;
- this.randomColors[6] = Color.cyan;
- this.randomColors[7] = Color.green;
- this.randomColors[8] = Color.pink;
- this.randomColors[9] = Color.gray;
- this.jitterThread = new Thread(this);
- }
-
- public void start() {
- if (this.jitterThread != null) {
- this.jitterThread.start();
- }
-
- }
-
- public void stop() {
- if (this.jitterThread != null) {
- this.jitterThread.stop();
- }
-
- this.jitterThread = null;
- }
-
- public void run() {
- for(; this.jitterThread != null; ((Component)this).repaint()) {
- try {
- Thread.sleep(200L);
- } catch (InterruptedException var1) {
- }
- }
-
- System.exit(0);
- }
-
- public boolean mouseDown(Event var1, int var2, int var3) {
- if (this.threadSuspended) {
- this.jitterThread.resume();
- this.normal = false;
- } else {
- this.normal = true;
- ((Component)this).repaint();
- this.jitterThread.suspend();
- }
-
- this.threadSuspended = !this.threadSuspended;
- return true;
- }
-
- public void paint(Graphics var1) {
- if (this.normal) {
- var1.setColor(this.bgColor);
- var1.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- var1.setColor(this.textColor);
- var1.setFont(this.font);
- var1.drawString(this.field_0, (((Component)this).size().width - this.field_1.stringWidth(this.field_0)) / 2, this.baseline);
- }
-
- }
-
- public void update(Graphics var1) {
- this.offScrGC.setColor(this.bgColor);
- this.offScrGC.fillRect(0, 0, ((Component)this).size().width, ((Component)this).size().height);
- this.offScrGC.setColor(this.textColor);
- this.offScrGC.setFont(this.font);
- if (!this.normal) {
- int var3 = 0;
-
- for(int var4 = 0; var4 < this.field_0.length(); ++var4) {
- if (this.randomColor) {
- Color var2;
- while(this.bgColor == (var2 = this.randomColors[Math.min(9, (int)(Math.random() * (double)10.0F))])) {
- }
-
- this.offScrGC.setColor(var2);
- }
-
- var3 += (int)(Math.random() * (double)10.0F);
- int var5 = this.baseline - (int)(Math.random() * (double)10.0F);
- String var6 = this.field_0.substring(var4, var4 + 1);
- this.offScrGC.drawString(var6, var3, var5);
- var3 += this.field_1.stringWidth(var6);
- }
- } else {
- this.offScrGC.drawString(this.field_0, (((Component)this).size().width - this.field_1.stringWidth(this.field_0)) / 2, this.baseline);
- }
-
- var1.drawImage(this.offScrImage, 0, 0, this);
- }
-
- private Color parseColorString(String var1) {
- if (var1.length() == 6) {
- int var2 = Integer.valueOf(var1.substring(0, 2), 16);
- int var3 = Integer.valueOf(var1.substring(2, 4), 16);
- int var4 = Integer.valueOf(var1.substring(4, 6), 16);
- return new Color(var2, var3, var4);
- } else {
- return Color.lightGray;
- }
- }
- }
-